Option Explicit
Sub F_Sample043()
    'Microsoft DAO 3.6 Object Library ]wޥζ
    'bF_Sample033һs@XӪNewDB.mdb
    'bF_Sample037һs@XӪwqg DAO_TABLEDEF
    Dim myDb      As DAO.Database
    Dim mytbl     As DAO.TableDef
    Dim myIdx     As DAO.Index
    Dim mySht     As Worksheet
    Dim i         As Long
    Dim myFileName As String
    myFileName = ThisWorkbook.Path & "\NewDb.mdb"	'wɮצW
    'wqg
    On Error Resume Next
    Set mySht = Worksheets("DAO_TABLEDEF")		'wW
    On Error GoTo 0
    If mySht Is Nothing Then
        MsgBox "wqsbC"
        Exit Sub
    End If
    mySht.Activate
    Set myDb = OpenDatabase(myFileName)
    On Error Resume Next
   'RJs
    myDb.TableDefs.Delete Cells(2, 1).Value
    On Error GoTo 0
    Set mytbl = myDb.CreateTableDef(Cells(2, 1).Value)
    Set myIdx = mytbl.CreateIndex("PrimaryKey")
    myIdx.Primary = True
    For i = 3 To Range("A1").End(xlDown).Row
       'ƶتs@
        With mytbl
            .Fields.Append .CreateField(Cells(i, 2).Value, _
                GetConstNo_DAO(Cells(i, 3).Value), Cells(i, 4).Value)
            'bxsF""ťզrꪺؤ]wAllowZeroLength
            If Cells(i, 3).Value = "dbText" Then
                If Cells(i, 5).Value = True Then
                    .Fields(Cells(i, 2).Value).AllowZeroLength = True
                End If
            End If
           'DKEYs@
            If Cells(i, 6).Value = "P" Then
                myIdx.Fields.Append myIdx.CreateField(Cells(i, 2).Value)
            End If
        End With
    Next i
    'NwqxsƮw
    mytbl.Indexes.Append myIdx
    myDb.TableDefs.Append mytbl
    myDb.Close
    Set mySht = Nothing					'
    Set myIdx = Nothing
    Set mytbl = Nothing
    Set myDb = Nothing
End Sub
